package com.hudongwx.godoffood.activity.myActivity;

import android.support.v4.app.FragmentTabHost;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabWidget;
import android.widget.TextView;

import com.hudongwx.godoffood.R;
import com.hudongwx.godoffood.fragment.myFragment.AllOrderFragment;
import com.hudongwx.godoffood.fragment.myFragment.AlreadyFailedFragment;
import com.hudongwx.godoffood.fragment.myFragment.AlreadyPayFragment;
import com.hudongwx.godoffood.fragment.myFragment.NoPaymentFragment;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

@ContentView(R.layout.activity_my_order)
public class MyOrderActivity extends AppCompatActivity {
    @ViewInject(android.R.id.tabhost)
    private FragmentTabHost fragmentTabHost;
    private TabWidget tabWidget;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
        fragmentTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("allOrder").setIndicator(getTab("全部订单",R.drawable.my_order_tab_iv)), AllOrderFragment.class, null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("noPay").setIndicator(getTab("未付款",R.drawable.my_order_tab_iv)), NoPaymentFragment.class, null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("alreadyPay").setIndicator(getTab("已付款",R.drawable.my_order_tab_iv)), AlreadyPayFragment.class, null);
        fragmentTabHost.addTab(fragmentTabHost.newTabSpec("AlreadyFailed").setIndicator(getTab("已失效",R.drawable.my_order_tab_iv)), AlreadyFailedFragment.class, null);
        fragmentTabHost.getTabWidget().setDividerDrawable(null);
        tabWidget = fragmentTabHost.getTabWidget();

    }
    private View getTab(String text,int img){
        View view = getLayoutInflater().inflate(R.layout.my_order_tab, null);
        TextView tv = (TextView) view.findViewById(R.id.my_order_tab_tv);
        ImageView iv = (ImageView) view.findViewById(R.id.my_order_tab_iv);
        tv.setText(text);
        iv.setImageResource(img);
        return view;
    }
    //返回拦截
    @Event(R.id.my_order_iv_back)
    private void back(View view) {
        finish();
    }
}
